﻿<?php
session_start();
include("admin_resist_mdl.php");
?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php

include("../../Modules/conn.php");

$msbm_old = $_GET["msbm"];
$msbm_new = $_POST["txtMSBM"];
$tenbm = $_POST["txtTenBM"];
$makhoa = $_POST["cboKhoa"];

// Kiem tra msbm
$queryMSBM = "select * from bo_mon where MSBM = '$msbm_new' and MSBM <> '$msbm_old')";
$resultMSBM = mysql_query($queryMSBM, $conn) or die(mysql_error());
$count = mysql_num_rows($resultMSBM);

if ($count > 0)
{
	header("Location: ../View/admin_cpanel.php?part=editcnbm&msbm=$msbm_old&info=dupmsbm");
}
else
{
	// Sua thong tin bo mon
	$queryUpdCNBM = "update bo_mon set MSBM = '$msbm_new', MA_KHOA = '$makhoa', TEN_BM = '$tenbm' where MSBM = '$msbm_old'";
	mysql_query($queryUpdCNBM, $conn) or die(mysql_error());
	
	mysql_close();
	header("Location: ../View/admin_cpanel.php?info=editcnbmsucc");
}

?>